<template>
	<view>
		<uni-forms :value="detailInfo" ref="form" validateTrigger="bind" class="word5">
			<uni-forms-item required label="企业名称" name="企业名称">
				<input maxlength="50" placeholder="请输入企业名称" v-model="detailInfo['企业名称']" @input="binddata('企业名称',$event.detail.value)">
			</uni-forms-item>
			<uni-forms-item required label="法人代表：" name="法定代表人">
				<input maxlength="50" v-model="detailInfo['法定代表人']" placeholder="请输入法人代表" @input="binddata('carNo',$event.detail.value)">
			</uni-forms-item>
			<uni-forms-item required label="企业地址" name="carPlate">
				<input maxlength="50" placeholder="请输入企业地址" v-model="detailInfo['地址']" @input="binddata('carPlate',$event.detail.value)">
			</uni-forms-item>
			<uni-forms-item required label="安全负责人：" name="企业安全负责人">
				<input maxlength="50" placeholder="请输入设施编号" v-model="detailInfo['企业安全负责人']" @input="binddata('carNo',$event.detail.value)">
			</uni-forms-item>
			<uni-forms-item required label="联系电话：" name="负责人电话">
				<input maxlength="18" placeholder="请输入检查地点" v-model="detailInfo['负责人电话']" @input="binddata('personId',$event.detail.value)">
			</uni-forms-item>
			<uni-forms-item required name="status" label="消防重点对象：">
				<!-- <uni-data-checkbox v-model="detailInfo['消防重点关注对象']" :localdata="status"></uni-data-checkbox> -->
			</uni-forms-item>
			<uni-forms-item required label="社会信用代码：" name="统一社会信用代码">
				<input maxlength="18" v-model="detailInfo['统一社会信用代码']" placeholder="请输入社会信用代码" @input="binddata('location',$event.detail.value)">
			</uni-forms-item>
			<uni-forms-item required name="经营状态" label="经营状态：">
				<!-- <uni-data-checkbox v-model="detailInfo['经营状态']" :localdata="status"></uni-data-checkbox> -->
			</uni-forms-item>
			<uni-forms-item label="成立时间：" name="成立日期">
				<date-picker placeHolder="请填写生产日期" v-model="detailInfo['成立日期']" @input="binddata('date',$event)"></date-picker>
			</uni-forms-item>
			<uni-forms-item label="核准日期" name="date1">
				<date-picker placeHolder="请填写核验日期" v-model="detailInfo['核实日期']" @input="binddata('date1',$event)"></date-picker>
			</uni-forms-item>
			<uni-forms-item label="经营期限" name="value">
				<view :class="label == '请选择设施类型' ? 'color':''" class="tap" @click="handleTap('picker')">{{label}}</view>
				<lb-picker ref="picker" @click="handleTap('picker')" @input="binddata('value',$event)" v-model="detailInfo['经营期限']"
				 mode="selector" :list="installTypeList" :dataset="{ name: 'label' }" @confirm="handleConfirm" @cancel="handleCancel">
				</lb-picker>
			</uni-forms-item>
			<uni-forms-item label="企业人数：" name="location">
				<input maxlength="18" placeholder="请输入具体位置" v-model="detailInfo['企业人数']" @input="binddata('location',$event.detail.value)">
			</uni-forms-item>
			<uni-forms-item label="企业登记类型：" name="value">
				<view :class="label == '请选择企业登记类型：' ? 'color':''" class="tap" @click="handleTap('picker')">{{label}}</view>
				<lb-picker ref="picker" @click="handleTap('picker')" @input="binddata('value',$event)" v-model="detailInfo['企业登记类型']"
				 mode="selector" :list="installTypeList" :dataset="{ name: 'label' }" @confirm="handleConfirm" @cancel="handleCancel">
				</lb-picker>
			</uni-forms-item>
			<uni-forms-item label="工作区域面积：" name="date">
				<date-picker placeHolder="请填写生产日期" v-model="detailInfo['工作区域面积']" @input="binddata('date',$event)"></date-picker>
			</uni-forms-item>
			<uni-forms-item label="备注信息：" name="date1">
				<date-picker placeHolder="请填写备注信息" v-model="detailInfo['备注']" @input="binddata('date1',$event)"></date-picker>
			</uni-forms-item>
		</uni-forms>
	</view>
</template>

<script>
	import uploader from '@/myComponents/image-uploader.vue'
	import DatePicker from '@/myComponents/date-picker.vue'
	import LbPicker from '@/components/lb-picker/index.vue'
	export default {
		components: {
			uploader,
			DatePicker,
			LbPicker
		},
		data() {
			return {
				label: '请选择设施类型',
				installTypeList: this.$type.installTypeList,
				detailInfo: {
					企业名称: '',
					法定代表人: '',
					成立日期: '2012-11-12',
					经营期限: '',
					地址: '',
					企业安全负责人: '',
					负责人电话: '12121212',
					企业人数: '10-20人',
					统一社会信用代码: '123123123',
					经营状态: "xxx",
					核实日期: '2020-12-12',
					企业登记类型: "sss",
					登记机关: '2323登记机关23',
					工作区域面积: '22',
					消防重点关注对象: true,
					备注: "备注备注备注备注",
					照片上传: [{
						id: 'xxxx'
					}]
				},
				//表单验证规则
				rules: {
					企业名称: {
						rules: [{
							required: true,
							errorMessage: '请填写企业名称',
						}]
					},
					经营状态: {
						rules: [{
							required: true,
							format: 'string',
							errorMessage: '请选择经营状态',
						}]
					}
				}
			}
		},
		onReady() {
			// 需要在onReady中设置规则
			this.$refs.form.setRules(this.rules)
		},
		methods: {
			setFields(detailInfo) {
				this.detailInfo = detailInfo
			},
			submitForm(form) {
				// console.log('this.resident', this.resident)
				// 手动提交表单
				return this.$refs.form.submit()
				// this.$refs.form.submit().then(res => {
				// 	console.log(res)
				// 	this.$emit('submit',res)
				// }).catch(err => {
				// 	this.$emit('submit',null)
				// 	console.log('表单错误信息：', err);
				// 	uni.showToast({
				// 		icon: 'none',
				// 		title: "表单字段填写错误，请检查"
				// 	})
				// })
			}
		}
	}
</script>

<style>

</style>
